package buzzerproxy.bprot; import java.net.ServerSocket; import java.net.Socket; import buzzerproxy.handler.ExceptionHandler; import buzzerproxy.handler.QuestionInterface; /** * * @author M. Friedeboldt */ public class ByteProtServer extends Thread { private int port; private ExceptionHandler handler; private SessionManager sessionManager; private QuestionInterface questionInterface; /** * * @param port * @throws Exception */ public ByteProtServer(int port, QuestionInterface questionInterface, ExceptionHandler handler) { this.port = port; this.handler = handler; this.questionInterface = questionInterface; } @Override public void run() { try { // create Server ServerSocket socket = new ServerSocket( port ); // Session Manager sessionManager = new SessionManager( questionInterface ); // Wait... while ( true ) { System.out.println( "wait for ...." ); Socket sock = socket.accept(); System.out.println( "accept() ..." ); new ByteProtComm( sock, sessionManager ).start(); } } catch ( Exception e ) { handler.throwException( e ); } } }